Trying to make a binned data plot: lots of small numbers; some really big ones.


In [3]:
%pylab inline
from numpy import *
from pylab import *


Populating the interactive namespace from numpy and matplotlib

In [8]:
xdata = range(0, 1000, 1)

In [12]:
figure()
hist(xdata)
show()



In [14]:
# Events are the number of occurrences in each bin
events


Out[14]:
array([ 100.,  100.,  100.,  100.,  100.,  100.,  100.,  100.,  100.,  100.])

In [15]:
#edges are the bounds of each bin. This is what you want to set for your log data.
edges


Out[15]:
array([   0. ,   99.9,  199.8,  299.7,  399.6,  499.5,  599.4,  699.3,
        799.2,  899.1,  999. ])

In [16]:
patches


Out[16]:
<a list of 10 Patch objects>

In [76]:
bins = []
for b in xrange(2, 35):
    if 2**b < 10000:
        bins.append(2**b)

In [77]:
hist(xdata, bins)
gca().set_xscale("log")



In [ ]: